<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<link
	href="${staticPath}/lib/datetimepicker/0.0.11/css/bootstrap-datetimepicker.min.css"
	rel="stylesheet" type="text/css">
<link href="${staticPath}/lib/chosen/1.1.0/chosen.min.css"
	rel="stylesheet" type="text/css">
<link rel="stylesheet"
	href="${staticPath}/lib/ztree/3.5/css/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script src="${staticPath}/lib/ztree/3.5/js/jquery.ztree.all-3.5.js"
	type="text/javascript"></script>
<script src="${staticPath}/js/jquery-dialog.js" type="text/javascript"></script>
<meta name="decorator" content="sysDefault"
	content="text/html; charset=utf-8" />
<script type="text/javascript">
	$(document).ready(function(){
		$(document).ready(function(){
			$("#stateForm")
			.validate(
					{
						submitHandler : function(form) {
							form.submit();
						},
						errorContainer : "#messageBox",
					});
	          });
		var opt = {
				service : "selectOneCountryService",
				idField : "countryCode",
				nameField : "countryName",
				title : "国家选择对话框"
			};
			$("#countryDialog").Dialog(opt);
			
	});

	function checkStateCode(code) {
		$.get("${contextPath}/sys/base/state/checkStateCode?code="
				+ code + "", function(data) {
			var text = eval("(" + data + ")");
			if (text.resCode == '1') {
				alert("省州编号已经存在");
				$('#code').val('');
			}
		});
	}
</script>
</head>
<body>
	<div class="container-fluid">
		<div class="row">
			<div class="col-xs-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">
							新增省州数据 <a class="btn btn-default btn-sm pull-right" role="button"
								href="javascript:void(0)" onclick="history.go(-1)">返回</a>
						</h3>
					</div>
					<div class="panel-body">
						<div class="col-xs-10">
							<div class="panel-body">
							<form:form id="stateForm" modelAttribute="sysBaseState"
								action="${contextPath}/sys/base/state/saveState"
								method="post" class="form-horizontal" role="form">
								<form:hidden path="id" />
								<div class="form-group">
									<div class="col-sm-6">
										<label for="name" class="col-sm-4 control-label">省州编号:</label>
										<div class="col-sm-8">
											<form:input id="code" path="code" htmlEscape="false"
												class="form-control required" onchange="checkStateCode(this.value)"/>
										</div>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-6">
										<label for="code" class="col-sm-4 control-label">省州名称:</label>
										<div class="col-sm-8">
											<form:input id="name" path="name" htmlEscape="false"
												class="form-control required"/>
										</div>
									</div>
								</div>
								<div class="form-group">
								       <div class="col-sm-6">
										 <label for="level" class="col-sm-4 control-label">所属国家:</label>
												<div class="input-group">
													<form:hidden path="countryCode" id="countryCode" />
												    <input type="text" class="form-control required" id="countryName"  readonly="readonly">
												    <span class="input-group-btn">
												      <button class="btn btn-primary" id="countryDialog" type="button">
												        	选择
												      </button>
												    </span>
											    </div>
										</div>
								</div>
								<div class="form-group">
								   <div class="col-sm-6">
										<div class="col-sm-4">
										</div>
										<div class="col-sm-8">
											<input class="btn btn-primary" type="submit" value="保 存" />
										</div>
								   </div>
								</div>
							</form:form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
</body>
</html>